//模拟lodash中的flowRight
// 数据优先，函数之后

const reverse = arr => arr.reverse()
const first = arr => arr[0]
const toUpper = s => s.toUpperCase()

// const f = _.flowRight(toUpper, first, reverse)
// const f = compose(toUpper, first, reverse)
// let a = ['one', 'two', 'three']
// console.log(f(a))

// function compose(...args) {
//     return function (value) {
//         return args.reverse().reduce(function (acc, fn) {
//             return fn(acc)
//         }, value)
//     }
// }
const compose = (...args) => value => args.reverse().reduce((acc, fn) => fn(acc), value)

const f = compose(toUpper, first, reverse)
let a = ['one', 'two', 'three']
console.log(f(a))
